Conversation
|
Claude finished @iamquang95's task in 2m 33s —— View job Code Review:
|
|
|
||
| fn decode_fixed_hex<const N: usize>(value: &str) -> Result<[u8; N], EthBeaconNodeApiClientError> { | ||
| let value = value.strip_prefix("0x").unwrap_or(value); | ||
| let bytes = hex::decode(value).map_err(|_| EthBeaconNodeApiClientError::UnexpectedType)?; |
There was a problem hiding this comment.
I see there are few EthBeaconNodeApiClientError::UnexpectedType returned in this file. Aren't they rather parsing errors? I would introduce new error type with a string member to write more about which parsing step failed.
| async fn fetch_genesis_data(&self) -> Result<serde_json::Value, EthBeaconNodeApiClientError> { | ||
| match self.get_genesis(GetGenesisRequest {}).await? { | ||
| GetGenesisResponse::Ok(genesis) => Ok(serde_json::json!({ | ||
| "genesis_time": genesis.data.genesis_time, |
There was a problem hiding this comment.
Is there a reason to pack it back to the JSON?
This would simplify the code:
async fn fetch_genesis_data(
&self,
) -> Result<GetGenesisResponseResponseData, EthBeaconNodeApiClientError> {
match self.get_genesis(GetGenesisRequest {}).await? {
GetGenesisResponse::Ok(genesis) => Ok(genesis.data),
_ => Err(EthBeaconNodeApiClientError::UnexpectedResponse),
}
}
Fix: #168